<template>
  <div>
    <!-- 轮播图 -->
    <!-- 头部组件 -->
    <header-nav></header-nav>
    <div class="banner">
      <div class="imgs">
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white" v-if="imgs">
          <van-swipe-item v-for="(item, index) in imgs" :key="index">
            <img :src="item.pic" />
          </van-swipe-item>
        </van-swipe>
      </div>
    </div>

    <!-- 推荐歌单 -->
    <div class="remLists">
      <div class="title">推荐歌单</div>
      <div class="content">
        <ul v-if="lists">
          <router-link tag="li" v-for="item in lists" :key="item.id" :to="'/rank/songlistdetails?id='+ item.id ">
            <div class="img">
              <img :src="item.picUrl" />
            </div>
            <p>{{ item.name }}</p>
            <span
              ><i class="iconfont icon-erji">
                {{ item.playCount | playCount }}</i
              ></span
            >
          </router-link>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import { getBanner, getPersonalized } from "../api/recommend";
import headerNav from "../components/base/headerNav.vue";
export default {
  components: {
    headerNav,
  },
  data() {
    return {
      imgs: null,
      lists: [],
    };
  },
  created() {
    getBanner().then((data) => {
      this.imgs = data.banners;
    });
    getPersonalized().then((data) => {
      this.lists = data.result;
    });
  },

  methods:{

  },

  filters: {
    playCount(value) {
      let w = value > 10000 ? (value / 10000).toFixed(1) : value;
      let hm = w > 10000 ? (w / 10000).toFixed(1) + "亿" : w + "万";
      return hm;
    },
  },
};
</script>
<style lang="less">
.banner {
  height: 134px;
  background-color: #d44439;
  width: 100%;
  position: relative;
  .imgs {
    position: absolute;
    left: 0px;
    top: 0px;
    right: 0px;
    margin: auto;
    width: 95.9%;
    overflow: hidden;
    border-radius: 4px;
    img {
      width: 100%;
    }
  }
}
.remLists {
  .title {
    height: 60px;
    line-height: 60px;
    text-indent: 5px;
    font-size: 16px;
    color: #000;
    font-weight: bold;
  }
  .content {
    padding-bottom: 24px;
    ul {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;
      li {
        flex: 0 0 32%;
        position: relative;
        span {
          position: absolute;
          top: 0px;
          right: 0px;
          color: #fff;
          font-size: 10px;
          i {
            font-size: 12px;
            vertical-align: middle;
          }
        }
        .img {
          min-height: 50px;
          width: 100%;
          border-radius: 3px;
          img {
            width: 100%;
            border-radius: 3px;
          }
        }
        p {
          font-size: 13px;
          color: #565658;
          padding: 5px 2px 0px 8px;
          height: 30px;
          padding: 5px;
          margin-bottom: 10px;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
        }
      }
    }
  }
}
</style>